package com.api.regression.group.createinternallink.folder;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.api.test.AssertApi;
import com.api.test.UrnType;
import com.zyncro.api.IGroupApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.ObjectResultApi;

@ContextConfiguration(locations = { "classpath:/group/group-context.xml" })
public class CreateInternalLink extends AbstractApiTest {

	@Value("#{editgroupdocuments['user.editor'].appId}")
	private String userUrn;

	@Value("#{editgroupdocuments['user.editor'].password}")
	private String userPassword;

	@Value("#{editgroupdocuments['group.toCreate'].urn}")
	private String groupUrn;

	@Value("#{editgroupdocuments['group.toCreate'].folderUrn}")
	private String groupFolderUrn;

	@Value("#{editgroupdocuments['group.toCreate'].fileUrn}")
	private String documentUrn;

	@BeforeClass
	protected void loginUser() throws Exception {

		getApi().login(userUrn, userPassword);
	}

	@Test
	public void testGetGroup() throws ZyncroApiException {

		ObjectResultApi<String> result = getApi().getService(IGroupApiService.class).createInternaLinkByDocumentId(groupUrn,
				groupFolderUrn, documentUrn);

		AssertApi.assertUrnType(result.getObject(), UrnType.DOCUMENT);
	}
}
